package cn.edu.scau.cmi.luochenghao.chapter06;

abstract class Geometry_ {
	public abstract double getArea();
}

class Rect extends Geometry_ {
	double a,b;
	Rect(double a,double b) {
		this.a=a;
		this.b=b;
	}
	public double getArea() {
		return a*b;
	}
}

class Circle_ extends Geometry_ {
	double r;
	Circle_(double r) {
		this.r=r;
	}
	public double getArea() {
		return(3.14*r*r);
	}
}

class Student_ {
	public double area(Geometry_...p) {
		double sum=0;
		for(Geometry_ i:p) {
			sum+=i.getArea();
		}
		return sum;
	}
}

public class MainClass {

	public static void main(String[] args) {
		Student_ zhang=new Student_();
		double area=zhang.area(new Rect(2,3),new Circle_(5.2),new Circle_(12));
		System.out.printf("2个圆和1个矩形图形的面积和：\n%10.3f",area);

	}

}
